-
-
Notifications
You must be signed in to change notification settings - Fork 395
Rewrite of the print_table function: module "output" __init__.py #2827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Rewrite of the print_table output method. This is in response to the need for greater control over column widths and other formatting options. The method is rewritten to directly output an HTML table instead of the original markdown approach. It introduces more CSS options through classes. This in turn allows different formatting options to be specified for each table in the same output window (which was limited in the original). The new funcionality can be optionally called with new kwargs. If these are not specified, the original functionality of the old print_table is maintained. It adds some data validation to check that arguments of type list are of the same length. Finally, this contribution should male it easier to later implement HTML colspan options to make more flexible tables.
Small optimisation removing superfluous else s in the table_check_input_lists method
Minor update, addin the border style to the header row.
Unable to perform a code review. You have run out of credits 😔 |
|
||
# Set a unique ID for each table | ||
# This is used in HTML tags to define CSS classes for formatting per table | ||
table_uid = random.randint(10000, 99999) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better use a counter, there is a small chance you hit a bug
set the variable somewhere higher:
self._table_counter = 0
then
self._table_counter += 1
table_uid = self._table_counter
Have you tested it on tools containing old table behaviour: preflight checks audit all, line counter for example |
if it works well, this is a ool change that could require documentation on the notion docs. |
Hi Jean-Marc, |
2025-10-01. Following JMC comments 31: Remove random import (from pyrevit.coreutils) 97: Add new __init__ to PyRevitOutputWindow class for a _table_counter 610: Correct logical error in kwarg validation 686: Implement _table_counter 755: Replace verbose if with a compact one.
I have made a new Commit with the suggested changes. |
- Added border_style parameter to table_html_header method for customizable table header styling. - Updated docstrings for table_html_header and table_check_input_lists methods to include examples and clarify argument types. - Improved input validation in table_check_input_lists to ensure consistent list lengths and provide detailed error messages.
Can you take the content of the said page and make a new one on your own notion account, share me the link to update. |
📦 New work-in-progress (wip) builds are available for 5.2.0.25280+0218-wip |
📦 New work-in-progress (wip) builds are available for 5.2.0.25280+1054-wip |
📦 New work-in-progress (wip) builds are available for 5.2.0.25280+1057-wip |
Hi. Yes, I'll get started on the Notion page. |
Rewrite of the print_table output method.
This is in response to the need for greater control over column widths and other formatting options such as borders, alignments, and row striping.
The method is rewritten to directly output an HTML table instead of the original markdown approach. It introduces more CSS options through classes. This in turn allows different formatting options to be specified for each table in the same output window (which was limited in the original).
The new functionality can be optionally called with new kwargs. If these are not specified, the original functionality of the old print_table is maintained.
It adds some data validation to check that arguments of type list are of the same length.
Another improvement: It allows several tables in one output to have their own formatting options.
Finally, this contribution should make it easier to later implement HTML
colspan
options to make more flexible tables/Checklist OK
Related Issues
https://discourse.pyrevitlabs.io/t/pyrevit-output-table-formatting/1532/13
Additional Notes
I attach a button script that runs the new method to show it in action.
Nobody asked for contribution, but it is very useful to me already.
I am sure my python is amateurish, but I think it works well.
TABOUTPUTDEV_script.py